home *** CD-ROM | disk | FTP | other *** search
- /****i* SOURCE_FILE/INFO
- *
- * NAME
- * Formatter.js
- *
- * USAGE
- * Part of Netobjects JavaScript Library.
- *
- * COPYRIGHT
- * Copyright ⌐ 2000-2005 Website Pros, Inc.
- * All Rights Reserved.
- *
- * This is an unpublished work protected by Website Pros, Inc.
- * as a trade secret, and is not to be used or disclosed except as
- * expressly provided in a written license agreement executed by
- * you and Website Pros, Inc.
- *
- * <copyright@websitepros.com>
- *
- * NOTES
- * JavaScript code.
- *
- *****/
-
- if (!IS_isModuleInitialized("IS.NOF.UTIL.LOGGING.Formatter"))
- {
- /****h* NOF_JavaScript_Library/NOF.UTIL.LOGGING.Formatter
- *
- * NAME
- * NOF.UTIL.LOGGING.Formatter
- *
- * DESCRIPTION
- *
- * A Formatter instance is used by a Handler to transform a log record
- * into a string.
- *
- * External dependencies: NOF.TEXT.MessageFomat
- ****/
-
- /**
- * constructor
- *
- **/
- function LOGGING_Formatter( ) {
- this.__proto__ = LOGGING_Formatter.prototype;
- }
- {
- var member = LOGGING_Formatter.prototype;
- member.CLASS_NAME = "LOGGING.Formatter";
-
- var method = LOGGING_Formatter.prototype;
-
- /**
- * Format the log record. This method should be considered as abstract,
- * here it just return the source class name, the source method name and
- * the result of the call to <code>formatMessage</code> method.
- *
- * @param logRecord the log record object created by the logger
- * @return the string representing the formatted message
- **/
- method.format = function (/*NOF.UTIL.LOGGING.LogRecord*/ logRecord) {
- var str = "";
- var scn = logRecord.getSourceClassName();
- var smn = logRecord.getSourceMethodName()
- if (scn != null) {
- str += scn + "::";
- }
- if (smn != null) {
- str += smn + " > ";
- }
- str += this.formatMessage(logRecord);
- return str;
- }
-
- /**
- * This method does format the log record.
- * It use, if provided, the record's resource bundle to find the value
- * corresponding to the key specified by the record's message and use
- * <code>NOF.TEXT.MessageFomat.format(pattern, parameters)</code>
- * method with record's parameters to get the formatted text.
- *
- * @param logRecord the log record object created by the logger
- * @return the formatted string
- **/
- method.formatMessage = function (/*NOF.UTIL.LOGGING.LogRecord*/ logRecord) {
- var str = logRecord.getMessage();
- var rb = logRecord.getResourceBundle();
- if (rb != null) {
- var tmpStr = rb.getProperty(str);
- if (tmpStr != null) {
- str = tmpStr;
- }
- }
- var params = logRecord.getParameters();
- if ( (str != null) && (params != null) ) {
- str = NOF.TEXT.MessageFormat.format(str, params);
- }
-
- return str;
- }
- }
-
- LOGGING.__proto__.Formatter = LOGGING_Formatter;
- }